@extends('layout.main')

@section('css')
<link rel="stylesheet" href="/assets/js/plugins/datatables/media/css/dataTables.bootstrap.min.css" />
<link href="/assets/js/plugins/datatables/extensions/Responsive/css/responsive.dataTables.min.css" rel="stylesheet">
@endsection

@section('content')
<div class="row">
    <div class="col-lg-12">
        <div class="ibox float-e-margins">
            <h5>友情链接列表</h5>
            <div class="ibox-content m-b-sm border-bottom">
                <div class="row">
                    <div class="col-sm-4">
                        <div class="form-group">
                            @can('chkaccess',['App\Http\Controllers\SiteController@getFrilinkadd'])
                             <button class="btn btn-w-m btn-primary" type="button" onclick="location.href='/site/frilinkadd'">添加</button>
                            @endcan
                            @can('chkaccess',['App\Http\Controllers\SiteController@postFrilinkdel'])
                            <button class="btn btn-w-m btn-danger" type="button" onclick="batchdel('/site/frilinkdel')">删除</button>
                            @endcan
                        </div>
                    </div>
                </div>
                <div class="row">
                    <div class="col-sm-3">
                        <div class="form-group">
                            <label class="control-label" for="type_id">分类</label>
                            <select name="type_id" id="type_id" class="form-control">
                                <option value="0">全部</option>
                                <option value="1">首页</option>
                                <option value="2">素材</option>
                                <option value="3">专题</option>
                            </select>
                        </div>
                    </div>
                </div>
                <div class="row pull-right">
                    <button class="btn btn-w-m btn-primary" type="button" onclick="search();">查询</button>
                </div>
            </div>
            <div class="ibox-content">
                <div class="table-responsive">
                    <table id="tblist" class="table table-striped table-bordered table-hover dataTables-example" >
                        <thead>
                            <tr>
                                <th><input id="chkall" type="checkbox"></th>
                                <th>序号</th>
                                <th>标题</th>
                                <th>分类</th>
                                <th>地址</th>
                                <th>创建时间</th>
                                <th>最后编辑</th>
                                <th>状态</th>
                                <th>操作</th>
                            </tr>
                        </thead>
                    </table>
                    <div style="float:right;">
                    <input style="width:50px;" type="text" id="inputpage"  onkeyup="this.value=this.value.replace(/\D/g,'')"  onafterpaste="this.value=this.value.replace(/\D/g,'')">
                    <button style="float:right;" type="button" onclick="jumppage()">跳转</button>
                    </div>
                </div>

            </div>
        </div>
    </div>
</div>
@endsection



@section('js')
<!-- Data Tables -->
<script src="/assets/js/plugins/datatables/media/js/jquery.dataTables.min.js"></script>
<script src="/assets/js/plugins/datatables/media/js/dataTables.bootstrap.min.js"></script>
<script src="/assets/js/plugins/datatables/extensions/Responsive/js/dataTables.responsive.min.js"></script>
<!-- <script src="/public/js/plugins/datatables/media/dataTables.tableTools.min.js"></script> -->
<script>

    var mytable=$('#tblist').DataTable( {
        "pagingType": "full_numbers",
        "processing": true,
        "serverSide": true,
        "searching": false,
        "ajax": {
            "url": "/site/frilinkdatatable",
            "data": function ( d ) {
                // d.search_title = $('#title').val();
                // d.search_siteid = $('#site_id').val();
                d.search_typeid = $('#type_id').val();
                // d.search_statusat = $('#status_at').val();
            }
        },
        "order": [[ 1, "asc" ]],
        "columns": [
            { "name": "chk","orderable": false },
            { "name": "id" },
            { "name": "title" },
            { "name": "typename" },
            { "name": "url" ,"orderable": false},
            { "name": "created_at" },
            { "name": "updated_at" },
            { "name": "status_at" },
            { "name": "operate","orderable": false }
        ],
        "language": {
            "url": "/assets/js/plugins/datatables/dtch.json"
        }
    });
</script>
@endsection